import { computed, ref } from 'vue';
import { defineStore } from 'pinia';
import { useAccessStore, useUserStore } from '@vben/stores';

export const loadUseAccess = () => {
  const userStore = useUserStore();
  console.log(userStore.userRoles);
};

const ADMIN = 'ROLE_ADMIN';
const ORDINARY = 'ROLE_ORDINARY';

export const usePermissionsStore = defineStore('permissionsStore', () => {
  const accessStore = useAccessStore();
  const userStore = useUserStore();
  console.log(accessStore.accessCodes);
  console.log(userStore.userRoles);
  const $reset = () => {};

  const IsAdmin = computed(() => {
    let userRole: any = userStore.userRoles;
    return userRole == ADMIN;
  });

  const IsOrdinary = computed(() => {
    let userRole: any = userStore.userRoles;
    return userRole == ORDINARY;
  });

  return {
    $reset,
    IsAdmin,
    IsOrdinary,
  };
});
